/* ************************************************************************ */
/*                                                                          */
/*  Copyright (c)2005 Russell Weir | damonsbane _at_ gmail                  */
/*                                                                          */
/* This library is free software; you can redistribute it and/or            */
/* modify it under the terms of the GNU Lesser General Public               */
/* License as published by the Free Software Foundation; either             */
/* version 3.0 of the License, or (at your option) any later version.       */
/*                                                                          */
/* This library is distributed in the hope that it will be useful,          */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of           */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        */
/* Lesser General Public License or the LICENSE file for more details.      */
/*                                                                          */
/* ************************************************************************ */

package tzparser;

class AliasZone {
	public var name(default,null) : String;
	public var className(default,null) 	: String;
	public var packageName(default,null) 	: String;

	public var alias(default,null) : String;
	public var aliasClassName(default,null) 	: String;
	public var aliasPackageName(default,null) 	: String;

	public function new(name, alias) {
		this.name = name;
		this.alias = alias;

		var i : { classname: String, packagename: String }
			= Parser.zoneNameToClassVars(name);
		className = i.classname;
		packageName = i.packagename;

		i = Parser.zoneNameToClassVars(alias);
		aliasClassName = i.classname;
		aliasPackageName = i.packagename;
	}

	public function toString() : String {
		var data = StringTools.replace(ZoneAliasClassText,'%%p%%',aliasPackageName);
		data = StringTools.replace(data,'%%c%%',aliasClassName);
		data = StringTools.replace(data,'%%n%%',Parser.quotedString(alias));
		data = StringTools.replace(data,'%%actual%%',packageName+"."+className);
		return data;
	}


static var ZoneAliasClassText : String = "
/* THIS FILE is automatically generated by tzparser, do not modify */

/* ************************************************************************ */
/*                                                                          */
/*  Copyright (c)2005 Russell Weir                                          */
/*                                                                          */
/* This library is free software; you can redistribute it and/or            */
/* modify it under the terms of the GNU Lesser General Public               */
/* License as published by the Free Software Foundation; either             */
/* version 3.0 of the License, or (at your option) any later version.       */
/*                                                                          */
/* This library is distributed in the hope that it will be useful,          */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of           */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        */
/* Lesser General Public License or the LICENSE file for more details.      */
/*                                                                          */
/* ************************************************************************ */

package %%p%%;
import tz.ChangeRecord;

// ZoneAlias %%c%% for %%actual%%
class %%c%% extends tz.Zone {
	var _instance : tz.Zone;

	public function new() {
		super(%%n%%);
		_instance = new %%actual%%();
	}

	override public function getChanges() : Array<ChangeRecord> {
		return _instance.getChanges();
	}
	override public function getAbbrev() : Array<String> {
		return _instance.getAbbrev();
	}
}
";

}